if (!window.protocol) protocol = {};
protocol.ProtocolWaveletDelta = function() { this.operation = []; this.address_path = [];  };

protocol.ProtocolWaveletDelta.prototype.serialize = function()
{
	var data = {};
	data["1"] = this.hashed_version.serialize();
	data["2"] = this.author;
	var arr_3 = [];
	for( var i = 0; i < this.operation.length; ++i )
	{
		arr_3.push( this.operation[i].serialize() );
	}
	data["3"] = arr_3;
	var arr_4 = [];
	for( var i = 0; i < this.address_path.length; ++i )
	{
		arr_4.push( this.address_path[i] );
	}
	data["4"] = arr_4;
	return data;
};

protocol.ProtocolWaveletDelta.parse = function(data)
{
	if ( !data ) return null;
	var obj = new protocol.ProtocolWaveletDelta();
	obj.hashed_version = protocol.ProtocolHashedVersion.parse( data["1"] );
	obj.author = data["2"];
	var arr = [];
	var d = data["3"];
	for( var i = 0; i < d.length; ++i )
	{
		arr.push( protocol.ProtocolWaveletOperation.parse( d[i] ) );
	}
	obj.operation = arr;
	obj.address_path = data["4"];
	if ( !obj.hashed_version == null ) throw "Missing field hashed_version";
	if ( !obj.author == null ) throw "Missing field author";
	return obj;
};

protocol.ProtocolHashedVersion = function() {  };

protocol.ProtocolHashedVersion.prototype.serialize = function()
{
	var data = {};
	data["1"] = this.version;
	data["2"] = this.history_hash;
	return data;
};

protocol.ProtocolHashedVersion.parse = function(data)
{
	if ( !data ) return null;
	var obj = new protocol.ProtocolHashedVersion();
	obj.version = data["1"];
	obj.history_hash = data["2"];
	if ( !obj.version == null ) throw "Missing field version";
	if ( !obj.history_hash == null ) throw "Missing field history_hash";
	return obj;
};

protocol.ProtocolWaveletOperation = function() {  };

protocol.ProtocolWaveletOperation.prototype.has_add_participant = function() { return ( this.add_participant != null ); };

protocol.ProtocolWaveletOperation.prototype.has_remove_participant = function() { return ( this.remove_participant != null ); };

protocol.ProtocolWaveletOperation.prototype.has_mutate_document = function() { return ( this.mutate_document != null ); };

protocol.ProtocolWaveletOperation.prototype.has_no_op = function() { return ( this.no_op != null ); };

protocol.ProtocolWaveletOperation.prototype.serialize = function()
{
	var data = {};
	if ( this.has_add_participant() ) {
	data["1"] = this.add_participant;
	}
	if ( this.has_remove_participant() ) {
	data["2"] = this.remove_participant;
	}
	if ( this.has_mutate_document() ) {
	data["3"] = this.mutate_document.serialize();
	}
	if ( this.has_no_op() ) {
	data["4"] = this.no_op;
	}
	return data;
};

protocol.ProtocolWaveletOperation.parse = function(data)
{
	if ( !data ) return null;
	var obj = new protocol.ProtocolWaveletOperation();
	obj.add_participant = data["1"];
	obj.remove_participant = data["2"];
	obj.mutate_document = protocol.ProtocolWaveletOperation_MutateDocument.parse( data["3"] );
	obj.no_op = data["4"];
	return obj;
};

protocol.ProtocolWaveletOperation_MutateDocument = function() {  };

protocol.ProtocolWaveletOperation_MutateDocument.prototype.serialize = function()
{
	var data = {};
	data["1"] = this.document_id;
	data["2"] = this.document_operation.serialize();
	return data;
};

protocol.ProtocolWaveletOperation_MutateDocument.parse = function(data)
{
	if ( !data ) return null;
	var obj = new protocol.ProtocolWaveletOperation_MutateDocument();
	obj.document_id = data["1"];
	obj.document_operation = protocol.ProtocolDocumentOperation.parse( data["2"] );
	if ( !obj.document_id == null ) throw "Missing field document_id";
	if ( !obj.document_operation == null ) throw "Missing field document_operation";
	return obj;
};

protocol.ProtocolDocumentOperation = function() { this.component = [];  };

protocol.ProtocolDocumentOperation.prototype.serialize = function()
{
	var data = {};
	var arr_1 = [];
	for( var i = 0; i < this.component.length; ++i )
	{
		arr_1.push( this.component[i].serialize() );
	}
	data["1"] = arr_1;
	return data;
};

protocol.ProtocolDocumentOperation.parse = function(data)
{
	if ( !data ) return null;
	var obj = new protocol.ProtocolDocumentOperation();
	var arr = [];
	var d = data["1"];
	for( var i = 0; i < d.length; ++i )
	{
		arr.push( protocol.ProtocolDocumentOperation_Component.parse( d[i] ) );
	}
	obj.component = arr;
	return obj;
};

protocol.ProtocolDocumentOperation_Component = function() {  };

protocol.ProtocolDocumentOperation_Component.prototype.has_annotation_boundary = function() { return ( this.annotation_boundary != null ); };

protocol.ProtocolDocumentOperation_Component.prototype.has_characters = function() { return ( this.characters != null ); };

protocol.ProtocolDocumentOperation_Component.prototype.has_element_start = function() { return ( this.element_start != null ); };

protocol.ProtocolDocumentOperation_Component.prototype.has_element_end = function() { return ( this.element_end != null ); };

protocol.ProtocolDocumentOperation_Component.prototype.has_retain_item_count = function() { return ( this.retain_item_count != null ); };

protocol.ProtocolDocumentOperation_Component.prototype.has_delete_characters = function() { return ( this.delete_characters != null ); };

protocol.ProtocolDocumentOperation_Component.prototype.has_delete_element_start = function() { return ( this.delete_element_start != null ); };

protocol.ProtocolDocumentOperation_Component.prototype.has_delete_element_end = function() { return ( this.delete_element_end != null ); };

protocol.ProtocolDocumentOperation_Component.prototype.has_replace_attributes = function() { return ( this.replace_attributes != null ); };

protocol.ProtocolDocumentOperation_Component.prototype.has_update_attributes = function() { return ( this.update_attributes != null ); };

protocol.ProtocolDocumentOperation_Component.prototype.serialize = function()
{
	var data = {};
	if ( this.has_annotation_boundary() ) {
	data["1"] = this.annotation_boundary.serialize();
	}
	if ( this.has_characters() ) {
	data["2"] = this.characters;
	}
	if ( this.has_element_start() ) {
	data["3"] = this.element_start.serialize();
	}
	if ( this.has_element_end() ) {
	data["4"] = this.element_end;
	}
	if ( this.has_retain_item_count() ) {
	data["5"] = this.retain_item_count;
	}
	if ( this.has_delete_characters() ) {
	data["6"] = this.delete_characters;
	}
	if ( this.has_delete_element_start() ) {
	data["7"] = this.delete_element_start.serialize();
	}
	if ( this.has_delete_element_end() ) {
	data["8"] = this.delete_element_end;
	}
	if ( this.has_replace_attributes() ) {
	data["9"] = this.replace_attributes.serialize();
	}
	if ( this.has_update_attributes() ) {
	data["10"] = this.update_attributes.serialize();
	}
	return data;
};

protocol.ProtocolDocumentOperation_Component.parse = function(data)
{
	if ( !data ) return null;
	var obj = new protocol.ProtocolDocumentOperation_Component();
	obj.annotation_boundary = protocol.ProtocolDocumentOperation_Component_AnnotationBoundary.parse( data["1"] );
	obj.characters = data["2"];
	obj.element_start = protocol.ProtocolDocumentOperation_Component_ElementStart.parse( data["3"] );
	obj.element_end = data["4"];
	obj.retain_item_count = data["5"];
	obj.delete_characters = data["6"];
	obj.delete_element_start = protocol.ProtocolDocumentOperation_Component_ElementStart.parse( data["7"] );
	obj.delete_element_end = data["8"];
	obj.replace_attributes = protocol.ProtocolDocumentOperation_Component_ReplaceAttributes.parse( data["9"] );
	obj.update_attributes = protocol.ProtocolDocumentOperation_Component_UpdateAttributes.parse( data["10"] );
	return obj;
};

protocol.ProtocolDocumentOperation_Component_KeyValuePair = function() {  };

protocol.ProtocolDocumentOperation_Component_KeyValuePair.prototype.serialize = function()
{
	var data = {};
	data["1"] = this.key;
	data["2"] = this.value;
	return data;
};

protocol.ProtocolDocumentOperation_Component_KeyValuePair.parse = function(data)
{
	if ( !data ) return null;
	var obj = new protocol.ProtocolDocumentOperation_Component_KeyValuePair();
	obj.key = data["1"];
	obj.value = data["2"];
	if ( !obj.key == null ) throw "Missing field key";
	if ( !obj.value == null ) throw "Missing field value";
	return obj;
};

protocol.ProtocolDocumentOperation_Component_KeyValueUpdate = function() {  };

protocol.ProtocolDocumentOperation_Component_KeyValueUpdate.prototype.has_old_value = function() { return ( this.old_value != null ); };

protocol.ProtocolDocumentOperation_Component_KeyValueUpdate.prototype.has_new_value = function() { return ( this.new_value != null ); };

protocol.ProtocolDocumentOperation_Component_KeyValueUpdate.prototype.serialize = function()
{
	var data = {};
	data["1"] = this.key;
	if ( this.has_old_value() ) {
	data["2"] = this.old_value;
	}
	if ( this.has_new_value() ) {
	data["3"] = this.new_value;
	}
	return data;
};

protocol.ProtocolDocumentOperation_Component_KeyValueUpdate.parse = function(data)
{
	if ( !data ) return null;
	var obj = new protocol.ProtocolDocumentOperation_Component_KeyValueUpdate();
	obj.key = data["1"];
	obj.old_value = data["2"];
	obj.new_value = data["3"];
	if ( !obj.key == null ) throw "Missing field key";
	return obj;
};

protocol.ProtocolDocumentOperation_Component_ElementStart = function() { this.attribute = [];  };

protocol.ProtocolDocumentOperation_Component_ElementStart.prototype.serialize = function()
{
	var data = {};
	data["1"] = this.type;
	var arr_2 = [];
	for( var i = 0; i < this.attribute.length; ++i )
	{
		arr_2.push( this.attribute[i].serialize() );
	}
	data["2"] = arr_2;
	return data;
};

protocol.ProtocolDocumentOperation_Component_ElementStart.parse = function(data)
{
	if ( !data ) return null;
	var obj = new protocol.ProtocolDocumentOperation_Component_ElementStart();
	obj.type = data["1"];
	var arr = [];
	var d = data["2"];
	for( var i = 0; i < d.length; ++i )
	{
		arr.push( protocol.ProtocolDocumentOperation_Component_KeyValuePair.parse( d[i] ) );
	}
	obj.attribute = arr;
	if ( !obj.type == null ) throw "Missing field type";
	return obj;
};

protocol.ProtocolDocumentOperation_Component_ReplaceAttributes = function() { this.old_attribute = []; this.new_attribute = [];  };

protocol.ProtocolDocumentOperation_Component_ReplaceAttributes.prototype.has_empty = function() { return ( this.empty != null ); };

protocol.ProtocolDocumentOperation_Component_ReplaceAttributes.prototype.serialize = function()
{
	var data = {};
	if ( this.has_empty() ) {
	data["1"] = this.empty;
	}
	var arr_2 = [];
	for( var i = 0; i < this.old_attribute.length; ++i )
	{
		arr_2.push( this.old_attribute[i].serialize() );
	}
	data["2"] = arr_2;
	var arr_3 = [];
	for( var i = 0; i < this.new_attribute.length; ++i )
	{
		arr_3.push( this.new_attribute[i].serialize() );
	}
	data["3"] = arr_3;
	return data;
};

protocol.ProtocolDocumentOperation_Component_ReplaceAttributes.parse = function(data)
{
	if ( !data ) return null;
	var obj = new protocol.ProtocolDocumentOperation_Component_ReplaceAttributes();
	obj.empty = data["1"];
	var arr = [];
	var d = data["2"];
	for( var i = 0; i < d.length; ++i )
	{
		arr.push( protocol.ProtocolDocumentOperation_Component_KeyValuePair.parse( d[i] ) );
	}
	obj.old_attribute = arr;
	var arr = [];
	var d = data["3"];
	for( var i = 0; i < d.length; ++i )
	{
		arr.push( protocol.ProtocolDocumentOperation_Component_KeyValuePair.parse( d[i] ) );
	}
	obj.new_attribute = arr;
	return obj;
};

protocol.ProtocolDocumentOperation_Component_UpdateAttributes = function() { this.attribute_update = [];  };

protocol.ProtocolDocumentOperation_Component_UpdateAttributes.prototype.has_empty = function() { return ( this.empty != null ); };

protocol.ProtocolDocumentOperation_Component_UpdateAttributes.prototype.serialize = function()
{
	var data = {};
	if ( this.has_empty() ) {
	data["1"] = this.empty;
	}
	var arr_2 = [];
	for( var i = 0; i < this.attribute_update.length; ++i )
	{
		arr_2.push( this.attribute_update[i].serialize() );
	}
	data["2"] = arr_2;
	return data;
};

protocol.ProtocolDocumentOperation_Component_UpdateAttributes.parse = function(data)
{
	if ( !data ) return null;
	var obj = new protocol.ProtocolDocumentOperation_Component_UpdateAttributes();
	obj.empty = data["1"];
	var arr = [];
	var d = data["2"];
	for( var i = 0; i < d.length; ++i )
	{
		arr.push( protocol.ProtocolDocumentOperation_Component_KeyValueUpdate.parse( d[i] ) );
	}
	obj.attribute_update = arr;
	return obj;
};

protocol.ProtocolDocumentOperation_Component_AnnotationBoundary = function() { this.end = []; this.change = [];  };

protocol.ProtocolDocumentOperation_Component_AnnotationBoundary.prototype.has_empty = function() { return ( this.empty != null ); };

protocol.ProtocolDocumentOperation_Component_AnnotationBoundary.prototype.serialize = function()
{
	var data = {};
	if ( this.has_empty() ) {
	data["1"] = this.empty;
	}
	var arr_2 = [];
	for( var i = 0; i < this.end.length; ++i )
	{
		arr_2.push( this.end[i] );
	}
	data["2"] = arr_2;
	var arr_3 = [];
	for( var i = 0; i < this.change.length; ++i )
	{
		arr_3.push( this.change[i].serialize() );
	}
	data["3"] = arr_3;
	return data;
};

protocol.ProtocolDocumentOperation_Component_AnnotationBoundary.parse = function(data)
{
	if ( !data ) return null;
	var obj = new protocol.ProtocolDocumentOperation_Component_AnnotationBoundary();
	obj.empty = data["1"];
	obj.end = data["2"];
	var arr = [];
	var d = data["3"];
	for( var i = 0; i < d.length; ++i )
	{
		arr.push( protocol.ProtocolDocumentOperation_Component_KeyValueUpdate.parse( d[i] ) );
	}
	obj.change = arr;
	return obj;
};

protocol.ProtocolAppliedWaveletDelta = function() {  };

protocol.ProtocolAppliedWaveletDelta.prototype.has_hashed_version_applied_at = function() { return ( this.hashed_version_applied_at != null ); };

protocol.ProtocolAppliedWaveletDelta.prototype.serialize = function()
{
	var data = {};
	data["1"] = this.signed_original_delta.serialize();
	if ( this.has_hashed_version_applied_at() ) {
	data["2"] = this.hashed_version_applied_at.serialize();
	}
	data["3"] = this.operations_applied;
	data["4"] = this.application_timestamp;
	return data;
};

protocol.ProtocolAppliedWaveletDelta.parse = function(data)
{
	if ( !data ) return null;
	var obj = new protocol.ProtocolAppliedWaveletDelta();
	obj.signed_original_delta = protocol.ProtocolSignedDelta.parse( data["1"] );
	obj.hashed_version_applied_at = protocol.ProtocolHashedVersion.parse( data["2"] );
	obj.operations_applied = data["3"];
	obj.application_timestamp = data["4"];
	if ( !obj.signed_original_delta == null ) throw "Missing field signed_original_delta";
	if ( !obj.operations_applied == null ) throw "Missing field operations_applied";
	if ( !obj.application_timestamp == null ) throw "Missing field application_timestamp";
	return obj;
};

protocol.ProtocolSignedDelta = function() { this.signature = [];  };

protocol.ProtocolSignedDelta.prototype.serialize = function()
{
	var data = {};
	data["1"] = this.delta;
	var arr_2 = [];
	for( var i = 0; i < this.signature.length; ++i )
	{
		arr_2.push( this.signature[i].serialize() );
	}
	data["2"] = arr_2;
	return data;
};

protocol.ProtocolSignedDelta.parse = function(data)
{
	if ( !data ) return null;
	var obj = new protocol.ProtocolSignedDelta();
	obj.delta = data["1"];
	var arr = [];
	var d = data["2"];
	for( var i = 0; i < d.length; ++i )
	{
		arr.push( protocol.ProtocolSignature.parse( d[i] ) );
	}
	obj.signature = arr;
	if ( !obj.delta == null ) throw "Missing field delta";
	return obj;
};

protocol.ProtocolSignature = function() {  };

protocol.ProtocolSignature.SignatureAlgorithm = {SHA1_RSA:1};

protocol.ProtocolSignature.prototype.serialize = function()
{
	var data = {};
	data["1"] = this.signature_bytes;
	data["2"] = this.signer_id;
	data["3"] = this.signature_algorithm;
	return data;
};

protocol.ProtocolSignature.parse = function(data)
{
	if ( !data ) return null;
	var obj = new protocol.ProtocolSignature();
	obj.signature_bytes = data["1"];
	obj.signer_id = data["2"];
	obj.signature_algorithm = data["3"];
	if ( !obj.signature_bytes == null ) throw "Missing field signature_bytes";
	if ( !obj.signer_id == null ) throw "Missing field signer_id";
	if ( !obj.signature_algorithm == null ) throw "Missing field signature_algorithm";
	return obj;
};

protocol.ProtocolSignerInfo = function() { this.certificate = [];  };

protocol.ProtocolSignerInfo.HashAlgorithm = {SHA256:1,SHA512:2};

protocol.ProtocolSignerInfo.prototype.serialize = function()
{
	var data = {};
	data["1"] = this.hash_algorithm;
	data["2"] = this.domain;
	var arr_3 = [];
	for( var i = 0; i < this.certificate.length; ++i )
	{
		arr_3.push( this.certificate[i] );
	}
	data["3"] = arr_3;
	return data;
};

protocol.ProtocolSignerInfo.parse = function(data)
{
	if ( !data ) return null;
	var obj = new protocol.ProtocolSignerInfo();
	obj.hash_algorithm = data["1"];
	obj.domain = data["2"];
	obj.certificate = data["3"];
	if ( !obj.hash_algorithm == null ) throw "Missing field hash_algorithm";
	if ( !obj.domain == null ) throw "Missing field domain";
	return obj;
};

